import { http } from '@/utils/http/axios';
import { ContentTypeEnum } from '@/enums/httpEnum';
import { useGlobSetting } from '@/hooks/setting';
const globSetting = useGlobSetting();

// 从配置中获取Excel数据字典上传路径
const excelDictDownloadUrl = globSetting.excelDictDownloadUrl

const prefix = '/admin/cmn/dict';
/**
 * @description 分页获取医院设置信息
 */
export function findChildData(id) {
  return http.request({
    url: `${prefix}/findChildData/${id}`,
    method: 'GET'
  })
}

/**
 * @description 获取字典信息
 */
export function getDictByDictCode(dictCode) {
  return http.request({
    url: `${prefix}/findChildren/${dictCode}`,
    method: 'GET'
  })
}

/**
 * @description: 上传Excel字典文件
 */
export function uplodExcelDictFile(formData, opt) {
  return http.request(
    {
      url: `${prefix}/importData`,
      method: 'POST',
      params: formData,
      headers: { 'Content-Type': ContentTypeEnum.FORM_DATA },
    },
    opt,
    {
      successMessageText: '上传成功',
    }
  );
}

/**
 * @description 下载文件
 */
export function downloadExcelDictFile() {
  debugger
  window.open(excelDictDownloadUrl, '_self')
}